package com.rainsoftware.LicenseSystem.models.entity;

import com.rainsoftware.LicenseSystem.models.entity.base.BaseEntity;
import gaarason.database.annotation.Column;
import gaarason.database.annotation.Table;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;

@Data
@ToString(callSuper = true)
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@Table(name = "users")
public class SystemUser extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /** auto generator start **/

    @Column(name = "username")
    private String username;

    @Column(name = "password")
    private String password;

    @Column(name = "role", length = 16L)
    private String role;

    @Column(name = "email")
    private String email;

    @Column(name = "created_at", nullable = true)
    private LocalDateTime createdAt;

    @Column(name = "updated_at", nullable = true)
    private LocalDateTime updatedAt;


    /** auto generator end **/

    @Repository
    public static class Model extends BaseModel<SystemUser, Integer> {

    }

    public void setAsDeveloper() {
        role = "Developer";
    }

    public void setAsAdmin() {
        role = "Admin";
    }
}